<?php
	$query_history = "SELECT * FROM history WHERE history_status = '1' AND history_date != '' ORDER BY history_date DESC LIMIT 4";
	$row_history = $sdb->select("history", $query_history);

	$totalRows_history = count($row_history);
?>

<link href="simplecustomer.css" rel="stylesheet" type="text/css" />
<div class="headercontainer">
  <div class="header">
    <h1>Simple Customer</h1>
  <a href="index.php" class="menubuttons <?php if ($pagetitle==Dashboard) { echo menubuttonsactive; } ?>">Dashboard</a><a href="contacts.php" class="menubuttons <?php if ($pagetitle==Contact || $pagetitle==ContactDetails) { echo menubuttonsactive; } ?>">Contacts</a><span class="headerright">Logged in as <?php echo $row_userinfo['user_email']; ?> | <a href="logout.php">Log Out</a> | <a href="profile.php">Update Profile</a> </span><br clear="all" />
  </div>
  </div>

<?php if ($totalRows_history > 0) { ?>
<div class="historycontainer">Recent:

    <?php
    $ih = 0;
    do {
	$history_contact = $row_history[$ih]['Attributes']['history_contact'];
	$row_histcont = $sdb->getAttributes('contacts', $history_contact);
?>
    <a href="contact-details.php?id=<?php echo $history_contact; ?>"><?php echo $row_histcont['contact_first']; ?> <?php echo $row_histcont['contact_last']; ?></a> <?php if ($totalRows_history!=$ih + 1) {?> &middot; <?php } ?>
      <?php $ih++; } while ($ih < $totalRows_history); ?></div>
<?php } ?>